/*
 *                    COPYRIGHT NOTICE
 *
 *           This code is copyright protected by Freedom Inc.
 *
 *              2001-2012 All Rights Are Reserved
 */
package com.freedom.oldsong.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.apache.log4j.Logger;

import com.freedom.oldsong.system.model.MenuItem;
import com.thoughtworks.xstream.XStream;

/**
 * @author steven.wang
 *
 */
public final class MenuParser {
	
	private static final Logger logger=Logger.getLogger(MenuParser.class);
	
	private MenuParser(){
		
	}
	/**
	 * {@inheritDoc}
	 */
	public static MenuItem parseMenuItem(File menu) {
		
		XStream xstream = new XStream();
		xstream.alias("menu", MenuItem.class);
		
		try {
			return (MenuItem) xstream.fromXML(new FileInputStream(menu));
		} catch (FileNotFoundException e) {
			logger.error(e.getMessage());
			return null;
		}
		
	}

}
